﻿using CefSharp;
using CefSharp.WinForms;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyCef.cfg
{
   public sealed class MyCefSettings
    {
        public static void  SetCef() {
            var settings = new CefSettings()
            {
                AcceptLanguageList = "zh-CN",
                //缓存路径
                CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache")
            };
            //使WebRTC
            settings.CefCommandLineArgs.Add("enable-media-stream", "1");
            //忽略证书
            settings.CefCommandLineArgs.Add("--ignore-urlfetcher-cert-requests", "1");
            settings.CefCommandLineArgs.Add("--ignore-certificate-errors", "1");
            //禁止启用同源策略安全限制，禁止后不会出现跨域问题
            settings.CefCommandLineArgs.Add("--disable-web-security", "1"); 

            //执行依赖项检查以确保所有相关资源都在输出目录中。
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

        }
    }
}
